package com.foreveredu.propms.persist.hibernate;

import java.util.List;

import com.foreveredu.propms.domain.House;
import com.foreveredu.propms.domain.Utilities;
import com.foreveredu.propms.persist.IUtilitiesDao;

public class HibernateUtilitiesDao extends HibernateAbstractDao<Utilities, Integer>
		implements IUtilitiesDao {

	private static final long serialVersionUID = 1L;

	public HibernateUtilitiesDao() {
		super(Utilities.class);
	}

	@SuppressWarnings("unchecked")
	@Override
	public Utilities findByHouseAndDate(House house, int year, int month) {
		String hql = "from Utilities u where u.house.id=? and year=? and month=?";
		List<Utilities> uList = this.getHibernateTemplate().find(hql, new Object[]{house.getId(), year, month});
		Utilities u = null;
		if (uList != null && uList.size()>0) {
			u = uList.get(0);
		}
		return u;
	}

}
